<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BookSelf extends Model
{
    use HasFactory,HasDatetimeFormatter;

    public function floor()
    {
        return $this->belongsTo(Floor::class);
    }


    public static function getArea()
    {
        $data = self::with('floor')->get();

        $result = [];
        foreach ($data as $item){
            $result[$item->id] = $item->floor->name . ' - ' . $item->name;
        }

        return $result;
    }
}
